home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / othergnu / gp2st.zoo / gnuplot / term / atari.trm
Encoding:
Text File  |  1991-06-04  |  3.9 KB  |  192 lines

  1. /*        atari.trm
  2.  *
  3.  * VDI based graphics driver for gnuplot 2
  4.  *
  5.  * Written by Jens Tingleff, placed in the public domain, use at own
  6.  * risk.
  7.  *
  8.  * Slightly inspired by the driver written by
  9.  *  Joerg Heitkoetter
  10.  *  (heitkoet@lumpi.informatik.uni-dortmund.de).
  11.  */
  12. #include <osbind.h>
  13. #include <aesbind.h>
  14. #include <vdibind.h>
  15.  
  16. #define ST_TERM_NAME "atari"
  17.  
  18. /* line styles courtesy by SUN driver */
  19. static unsigned 
  20. int atari_styles[] = {  0xffff,0x1111,
  21.             0xffff,0x5555,0x3333,0x7777,0x3f3f,0x0f0f,0x5f5f };
  22.  
  23. #define SYS_STYLES    2                /* used by Gnuplot */
  24. #define MAX_STYLES    9                /* all styles */
  25. #define USR_STYLES    (MAX_STYLES-SYS_STYLES)        /* for user */
  26.  
  27.  
  28. #define ST_VTIC     8
  29. #define ST_HTIC     6
  30.  
  31. static char st_gotocmdln[128];
  32. static int st_vdihandle;
  33. static int st_workout[57];
  34. static enum JUSTIFY st_text_just = CENTRE;
  35. static int st_lastx, st_lasty, st_text_ang;
  36. static int st_xlast, st_ylast, st_hchar, st_vchar;
  37.  
  38.  
  39. ST_init()
  40. {
  41.     int    dummy, intin[11], i, phys_handle, 
  42.         n_rows, n_cols, attrib[10];
  43.     
  44.     phys_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
  45.     for(i=0; i<10; i++)
  46.     {
  47.     intin[i] = 1;
  48.     }
  49.     intin[10] = 2;
  50.     st_vdihandle = phys_handle;
  51.     v_opnvwk(intin, &st_vdihandle, st_workout);
  52.  
  53.     vq_chcells(st_vdihandle, &n_rows, &n_cols);
  54.     st_xlast = st_workout[0];
  55.  
  56.     /* Space for one line of console chars (not graphics text).    */
  57.     st_ylast = st_workout[1] - (st_workout[1] + 1)/n_rows;    
  58.     
  59.     vqt_attributes(st_vdihandle, attrib);
  60.     st_hchar = attrib[8];            /* Cell dimensions.    */
  61.     st_vchar = attrib[9];
  62.  
  63.     for(i=0; strcmp(term_tbl[i].name, ST_TERM_NAME) != 0; i++) /* Find */
  64.     {
  65.     /* nil */
  66.     }
  67.  
  68.     term_tbl[i].xmax = st_xlast;
  69.     term_tbl[i].ymax = st_ylast;
  70.     term_tbl[i].h_char = st_hchar;
  71.     term_tbl[i].v_char = st_vchar;
  72.     sprintf(st_gotocmdln, "\033Y%c%c", 32+(n_rows-1), 32);
  73.     printf("Set terminal \"%s\" to: xmax = %d, ymax = %d, "
  74.         "h_char = %d, v_char = %d\n", term_tbl[i].name,
  75.         term_tbl[i].xmax, term_tbl[i].ymax, term_tbl[i].h_char,
  76.         term_tbl[i].v_char);
  77. }
  78.  
  79.  
  80. ST_graphics()
  81. {
  82.     int array[4];
  83.     
  84.     fflush(stdout);
  85.     v_clrwk(st_vdihandle);
  86.     array[0] = array[1] = 0;
  87.     array[2] = st_xlast;
  88.     array[3] = st_ylast;
  89.     vs_clip(st_vdihandle, 1, array);
  90.  
  91.     Cursconf(0, 0);                    /* Hide cursor.    */
  92.     Cconws(st_gotocmdln);
  93.     vsl_type(st_vdihandle, 7);            /* User defined.    */
  94.     ST_justify_text(CENTRE);
  95. }
  96.  
  97.  
  98. ST_text()
  99. {
  100.     Cconws(st_gotocmdln);
  101.     Cursconf(1, 0);                    /* Showcursor.    */
  102. }
  103.  
  104.  
  105. ST_linetype(linetype)
  106. int linetype;
  107. {
  108.     if (linetype >= 0) 
  109.         linetype %= USR_STYLES;
  110.     vsl_udsty(st_vdihandle, atari_styles[linetype + SYS_STYLES]);
  111. }
  112.  
  113.  
  114. ST_move(x,y)
  115. int x,y;
  116. {
  117.     st_lastx = x;
  118.     st_lasty = (st_ylast - y) % (st_ylast+1);
  119. }
  120.  
  121.  
  122. ST_vector(x,y)
  123. int x,y;
  124. {
  125.     int    array[4];
  126.     
  127.     array[0] = st_lastx;
  128.     array[1] = st_lasty;
  129.     st_lastx = x;
  130.     st_lasty = (st_ylast - y) % (st_ylast+1);
  131.     array[2] = st_lastx;
  132.     array[3] = st_lasty;
  133.     v_pline(st_vdihandle, 2, array);
  134. }
  135.  
  136. ST_justify_text(mode)
  137. int mode;
  138. {
  139.     int hout, vout;
  140.     
  141.     /* Second param. to vst_alignment sets the vertical alignment to     */
  142.     /* be half.                                */
  143.     switch(mode)
  144.     {
  145.       case LEFT:
  146.     st_text_just = LEFT;
  147.     vst_alignment(st_vdihandle, 0, 1, &hout, &vout);
  148.     break;
  149.       case RIGHT:
  150.     st_text_just = RIGHT;
  151.     vst_alignment(st_vdihandle, 2, 1, &hout, &vout);
  152.     break;
  153.       case CENTRE:
  154.     st_text_just = CENTRE;
  155.     vst_alignment(st_vdihandle, 1, 1, &hout, &vout);
  156.     }
  157.     return TRUE;
  158. }
  159.  
  160. ST_text_angle(ang)
  161. int ang;
  162. {
  163.     st_text_ang = ang;
  164.     vst_rotation(st_vdihandle, (ang == 0 ? 0 : 900));
  165.     return TRUE;
  166. }
  167.  
  168.  
  169. ST_put_text(x, y, str)            /* x,y graphics coords.    */
  170. int x, y;
  171. char *str;
  172. {
  173.     v_gtext(st_vdihandle, x, (st_ylast - y) % (st_ylast + 1), str);
  174. } /* END of ST_put_text */
  175.  
  176.  
  177. ST_reset()
  178. {
  179.     int array[4];
  180.     
  181.     array[0] = array[1] = 0;
  182.     array[2] = st_xlast;
  183.     array[3] = st_ylast;
  184.     
  185.     v_clsvwk(st_vdihandle);
  186.     Cconws(st_gotocmdln);
  187.     vs_clip(st_vdihandle, 0, array);
  188.     
  189. }
  190.  
  191.  
  192.